﻿/** v 0.0.1 2016-09-29 by majie **/
!function(paramWindow){
	var staffCodeElement=document.getElementById('selfStaffCode');
	sessionStorage.setItem("scaffCodeValue", staffCodeElement.value);
	/**ajax方法**/
	paramWindow.ajax=function(options) {
        options = options || {};
        options.type = (options.type || "GET").toUpperCase();
        options.dataType = options.dataType || "json";
        var params = formatParams(options.data);

        //创建 - 非IE6 - 第一步
        if (window.XMLHttpRequest) {
            var xhr = new XMLHttpRequest();
        } else { //IE6及其以下版本浏览器
            var xhr = new ActiveXObject('Microsoft.XMLHTTP');
        }

        //接收 - 第三步
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                var status = xhr.status;
                if (status >= 200 && status < 300) {
                    options.success && options.success(xhr.responseText, xhr.responseXML);
                } else {
                    options.fail && options.fail(status);
                }
            }
        }

        //连接 和 发送 - 第二步
        if (options.type == "GET") {
            xhr.open("GET", options.url + "?" + params, true);
            xhr.send(null);
        } else if (options.type == "POST") {
            xhr.open("POST", options.url, true);
            //设置表单提交时的内容类型
            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xhr.send(params);
        }
    }
    //格式化参数
    function formatParams(data) {
        var arr = [];
        for (var name in data) {
            arr.push(encodeURIComponent(name) + "=" + encodeURIComponent(data[name]));
        }
        arr.push(("v=" + Math.random()).replace("."));
        return arr.join("&");
    }
	paramWindow.hasClass=function(dom, className) {
		className = className.replace(/^\s|\s$/g, "")

		return (
			" " + ((dom || {}).className || "").replace(/\s/g, " ") + " "
		).indexOf(" " + className + " ") >= 0
	}
	 // dom 元素处理
    // 获取dom属性
    function getAttr( attr )
    {
        return this.getAttribute( attr );
    }
    // 设置属性
    function setAttr( attr, val )
    {
        this.setAttribute( attr, val );
 
        return this;
    };
    // 编辑元素class
    function editClass( mode, data )
    {
        var cls = getAttr.call( this, "class" ) || '';
 
        var arr = cls.split( /\s+/ );
 
        switch( mode )
        {
            case "add":
 
                return setAttr.call( this, "class", cls + " " + data );
 
            break;
 
            case "remove":
 
                for( var i = 0; i < arr.length; i++ )
                {
                    if( arr[ i ] == data )
                    {
                        arr.splice( i, 1 );
                    }
                };
 
                var cls = arr.join( " " );
 
                cls = cls.replace( /^\s|\s$/g, "" );
 
                // cls = cls == "" ? null : cls;
 
                return setAttr.call( this, "class", cls );
 
            break;
 
            default:
 
                console.log( "EditClass mode error!" );
 
                return this;
 
            break;
        }
    }
    // 添加class
    paramWindow.addClass=function( cls ){
        return editClass.call( this, "add", cls );
    }
    // 删除class
    paramWindow.removeClass=function( cls )
    {
        return editClass.call( this, "remove", cls );
    }
}(window);
!function(paramWindow){
	
}(window);
/** 跳转页面**/
!function(paramWindow){
	paramWindow.obtainUrl={
			obtainDataDispatchUrl:function(){
			window.location.href="businessOpportunity.html";
	},
			obtainMarketingTasksUrl:function(){
			window.location.href="mytask.html";
	},
		}
		/** 跳转营销任务派单页面事件绑定**/
   var paramMarketingTasksElement=document.getElementById('marketingTasks');
	paramMarketingTasksElement.onclick = function(){
		//跳转营销任务派单页面事件点击处理
		paramWindow.obtainUrl.obtainMarketingTasksUrl();
	}
	  /** 跳转大数据商机页面事件绑定**/
	var paramDataDispatchElement=document.getElementById('dataDispatch');
	paramDataDispatchElement.onclick = function(){
		//跳转大数据商机页面事件点击处理
		paramWindow.obtainUrl.obtainDataDispatchUrl();
	}

	/** 跳转页面**/
}(window);
             //职位选择按钮弹出框处理start
!function(paramWindow) {
	//window对象表示浏览器中打开的窗口
    paramWindow.HANDLE_MYTASK_EVENT={
	    /**构造数据div id="content" 的div元素**/
	    mhowardFloorCoverPannelShow: function() {
            var mhowardFloorCoverPannelElement=document.getElementById('SearchCoverPannel7');
			console.log(mhowardFloorCoverPannelElement);
			var coverFloor=mhowardFloorCoverPannelElement.getElementsByClassName('cover-floor');
			console.log(coverFloor);
			paramWindow.removeClass.call(coverFloor[0], 'displayNone');
        },
		mhowardFloorCoverPannelHide: function() {
            var mhowardFloorCoverPannelElement=document.getElementById('SearchCoverPannel7');
			console.log(mhowardFloorCoverPannelElement);
			var coverFloor=mhowardFloorCoverPannelElement.getElementsByClassName('cover-floor');
			console.log(coverFloor);
			paramWindow.addClass.call(coverFloor[0], 'displayNone');
        },
		/**控制职位选择框内容的显示**/
		
		customSearchBoxHide:function(){
			var searchFastScreenElement=document.getElementById('searchFastScreen18');
			paramWindow.addClass.call(searchFastScreenElement, 'displayNone');
		},
		mhowardPopCoverShow:function(){
			/**layout_head class 去除max-zindex**/
			var layoutHeadElement=document.getElementById('layout_head');
			paramWindow.removeClass.call(layoutHeadElement, 'max-zindex');
			//mhoward-popCover
			var mhowardPopCoverElement=document.getElementsByClassName('mhoward-popCover');
			paramWindow.removeClass.call(mhowardPopCoverElement[0], 'displayNone');
			/**html标签 style 添加 height:100%**/
	        var htmlElement=document.getElementsByTagName("html");
			htmlElement[0].style.cssText = "height:100%;"
			/**search1 class 添加displayNone**/
			var search1Element=document.getElementById('search1');
			paramWindow.addClass.call(search1Element, 'displayNone');
			paramWindow.HANDLE_MYTASK_EVENT.mhowardFloorCoverPannelShow();
		},
		mhowardPopCoverHide:function(){
			//mhoward-popCover
			var mhowardPopCoverElement=document.getElementsByClassName('mhoward-popCover');
			paramWindow.addClass.call(mhowardPopCoverElement[0], 'displayNone');
            /**html标签 style去除 height:100%**/
			var htmlElement=document.getElementsByTagName("html");
			htmlElement[0].style.cssText = "";
			/**layout_head class 添加max-zindex**/
			var layoutHeadElement=document.getElementById('layout_head');
			paramWindow.addClass.call(layoutHeadElement, 'max-zindex');
			/**search1 class 去除displayNone**/
			var search1Element=document.getElementById('search1');
			paramWindow.removeClass.call(search1Element, 'displayNone');
			paramWindow.HANDLE_MYTASK_EVENT.mhowardFloorCoverPannelHide();
			
		},
   }
} (window);
              // 弹出框返回按钮处理end
/**
*
*/
!function(paramWindow) {
	   // 处理选择机构弹出框内容start
	function structureLoadProjectItems(data){
		/**
		    {
        "staffId": "123144",
        "bssOrgId": "371",
        "regionId": "2",
        "staffGradeId": "M",
        "staffCode": "18190709098",
        "staffName": "王艳春",
        "staffPwd": "qnC8u/tPJc9YQ+ZFzkyNfw==",
        "certTypeId": "88",
        "certNbr": "",
        "contactTel": "18190709098",
        "homeAddr": "",
        "effDate": "2016-03-28 00:00:00.0",
        "expDate": "2023-03-29 00:00:00.0",
        "state": "10A",
        "modiDate": "2016-03-28 10:18:22.0",
        "loginDate": "2016-10-10 10:06:13.0",
        "onlineState": "",
        "modifyPassDate": "2016-10-09 09:41:35.0",
        "magSeqNbr": "6",
        "jobId": "21090260",
        "createdDate": "2016-03-28 00:00:00.0",
        "magDesc": "",
        "stationId": "8866",
        "name": "阿坝市公司沙盘管理员",
        "jobDesc": "",
        "flag": "0",
        "keyFlag": "0"
            },
		**/
		// 构造选择机构弹出框元素start
		var valueOfGridDataItems=eval(data);
		var valueOfGridDataItem;
		var paramDomItem=new Array();
		var staffId;
		var bssOrgId;
		var regionId;
		var staffName;
		var jobId;
		var stationId;
		var name;
		for(var i=0; i<valueOfGridDataItems.length; i++){
			paramValueOfGridDataItem=new Array();			
            valueOfGridDataItem=eval(valueOfGridDataItems[i]);	
			staffId=valueOfGridDataItem.staffId;
			bssOrgId=valueOfGridDataItem.bssOrgId;
			regionId=valueOfGridDataItem.regionId;
			staffName=valueOfGridDataItem.staffName;
			jobId=valueOfGridDataItem.jobId;
			stationId=valueOfGridDataItem.stationId;
			name=valueOfGridDataItem.name;
			sessionStorage.setItem("station_bssorgid", bssOrgId);
			sessionStorage.setItem("station_regionid", regionId);
			sessionStorage.setItem("station_jobid", jobId);
			sessionStorage.setItem("station_staffId", staffId);
			paramValueOfGridDataItem.push('<li class="sidebar-iteam bdr-bom selectStationByStaffCode" ');
			paramValueOfGridDataItem.push(' station_bssOrgId="');
			paramValueOfGridDataItem.push(bssOrgId);
			paramValueOfGridDataItem.push('"');
			paramValueOfGridDataItem.push(' station_regionId="');
			paramValueOfGridDataItem.push(regionId);
			paramValueOfGridDataItem.push('"');
			paramValueOfGridDataItem.push(' station_staffId="');
			paramValueOfGridDataItem.push(staffId);
			paramValueOfGridDataItem.push('"');
			paramValueOfGridDataItem.push(' station_jobId="');
			paramValueOfGridDataItem.push(jobId);
			paramValueOfGridDataItem.push('"');
			paramValueOfGridDataItem.push('>');
			paramValueOfGridDataItem.push('<i class="arrow" id="checkedIcon">');
			paramValueOfGridDataItem.push('</i>');
			paramValueOfGridDataItem.push('<span class="sort-of-brand" id="userStationName">');
            paramValueOfGridDataItem.push(name);
			paramValueOfGridDataItem.push('</span>');
			paramValueOfGridDataItem.push('</li>');
			paramDomItem.push(paramValueOfGridDataItem.join(""));
		}
		var searchListElement =document.getElementById('bssOrgIdUl');
		searchListElement.innerHTML+=paramDomItem.join("");
		var selectStationByStaffCode=document.getElementsByClassName('selectStationByStaffCode');
		for(var i=0;i<selectStationByStaffCode.length;i++){
			selectStationByStaffCode[i].onclick = function(){
				for(var i=0;i<selectStationByStaffCode.length;i++){
					paramWindow.removeClass.call(selectStationByStaffCode[i], 'hasSelectThisJob');
					selectStationByStaffCode[i].getElementsByTagName("span")[0].style.color="black";
					selectStationByStaffCode[i].getElementsByTagName("i")[0].style.display="none";
				}
				var paramItem=this;
			    paramWindow.addClass.call(this, 'hasSelectThisJob');
				paramItem.getElementsByTagName("span")[0].style.color="#007ee2";
				paramItem.getElementsByTagName("i")[0].style.display="block";
			}
		}
	}
	// 构造选择机构弹出框元素end
   //window对象表示浏览器中打开的窗口
    paramWindow.HANDLE_MENUSELECT_EVENT={
		/**加载机构列表**/
		loadProjectItems:function(){
			 //查询机构列表	
			paramWindow.ajax({
				//请求地址
				url: "http://133.37.253.32:7002/ims/policy_library_index_show!queryStaffCodeForMobile.action",              
				type: "POST",//请求方式
				data: {"StaffCode":sessionStorage.getItem("scaffCodeValue")},//请求参数
				dataType: "json",
				success: function (response, xml) {
					//response为返回的结果集
					structureLoadProjectItems(eval("(" + response + ")"));
				},
				fail: function (status) {
					// 此处放失败后执行的代码
				}
			}); 
		},
		/**控制页数的显示**/
		pageNumElementShow:function(){
			var pageNumberElement=document.getElementById('searchlist49');
			paramWindow.removeClass.call(pageNumberElement, 'displayNone');
		},
		/**控制页数隐藏**/
		pageNumElementHide:function(){
		   	var pageNumberElement=document.getElementById('searchlist49');
			paramWindow.addClass.call(pageNumberElement, 'displayNone');
		},
	    /**构造数据div id="content" 的div元素**/
	    mhowardFloorCoverPannelShow: function() {
            var mhowardFloorCoverPannelElement=document.getElementById('SearchCoverPannel7');
			console.log(mhowardFloorCoverPannelElement);
			var coverFloor=mhowardFloorCoverPannelElement.getElementsByClassName('cover-floor');
			console.log(coverFloor);
			paramWindow.removeClass.call(coverFloor[0], 'displayNone');
        },
		mhowardFloorCoverPannelHide: function() {
            var mhowardFloorCoverPannelElement=document.getElementById('SearchCoverPannel7');
			console.log(mhowardFloorCoverPannelElement);
			var coverFloor=mhowardFloorCoverPannelElement.getElementsByClassName('cover-floor');
			console.log(coverFloor);
			paramWindow.addClass.call(coverFloor[0], 'displayNone');
        },
		customSearchBoxHide:function(){
			var searchFastScreenElement=document.getElementById('searchFastScreen18');
			paramWindow.addClass.call(searchFastScreenElement, 'displayNone');
		},
		mhowardPopCoverShow:function(){
			/**layout_head class 去除max-zindex**/
			var layoutHeadElement=document.getElementById('layout_head');
			paramWindow.removeClass.call(layoutHeadElement, 'max-zindex');
			//mhoward-popCover
			var mhowardPopCoverElement=document.getElementsByClassName('mhoward-popCover');
			paramWindow.removeClass.call(mhowardPopCoverElement[0], 'displayNone');
			/**html标签 style 添加 height:100%**/
	        var htmlElement=document.getElementsByTagName("html");
			htmlElement[0].style.cssText = "height:100%;"
			
			
			/**search1 class 添加displayNone**/
			var search1Element=document.getElementById('search1');
			paramWindow.addClass.call(search1Element, 'displayNone');
			paramWindow.HANDLE_MENUSELECT_EVENT.mhowardFloorCoverPannelShow();
		},
		mhowardPopCoverHide:function(){
			//mhoward-popCover
			var mhowardPopCoverElement=document.getElementsByClassName('mhoward-popCover');
			paramWindow.addClass.call(mhowardPopCoverElement[0], 'displayNone');
            /**html标签 style去除 height:100%**/
			var htmlElement=document.getElementsByTagName("html");
			htmlElement[0].style.cssText = "";
			/**layout_head class 添加max-zindex**/
			var layoutHeadElement=document.getElementById('layout_head');
			paramWindow.addClass.call(layoutHeadElement, 'max-zindex');
			/**search1 class 去除displayNone**/
			var search1Element=document.getElementById('search1');
			paramWindow.removeClass.call(search1Element, 'displayNone');

		},
   }
   // 处理选择机构弹出框内容end
} (window);
!function(paramWindow) {
       
	/**加载职位**/
	function loadProjectItemsItems(){
		paramWindow.HANDLE_MENUSELECT_EVENT.loadProjectItems();
	}
	/**页面中的元素加载成功后执行**/
	window.addEventListener("DOMContentLoaded",loadProjectItemsItems,false);
	var paramFilterElement=document.getElementById('selectPosition');
	paramFilterElement.onclick = function(){
		//职位选择按钮点击处理
		paramWindow.HANDLE_MYTASK_EVENT.mhowardPopCoverShow();
	}
    var paramFilterElement123=document.getElementById('searchitempanel23');
	paramFilterElement123.onclick = function(){
		//弹出框返回按钮点击处理
		paramWindow.HANDLE_MYTASK_EVENT.mhowardPopCoverHide();
	}
	var searchitempanel20Element=document.getElementById('searchitempanel20');
	searchitempanel20Element.onclick=function(){
		/**判断选中了哪个角色**/
		var selectStationByStaffCode=document.getElementsByClassName('selectStationByStaffCode');
		var point=0;
		var station_bssorgid;
		var station_regionid;
		var station_jobid;
		var station_staffId;
		for(var i=0;i<selectStationByStaffCode.length;i++){
			if(paramWindow.hasClass(selectStationByStaffCode[i], 'hasSelectThisJob')){
				//station_bssorgid="301" //station_regionid="2" //station_jobid="2040"
				station_bssorgid=selectStationByStaffCode[i].getAttribute('station_bssorgid');
				station_regionid=selectStationByStaffCode[i].getAttribute('station_regionid');
				station_jobid=selectStationByStaffCode[i].getAttribute('station_jobid');
				station_staffId=selectStationByStaffCode[i].getAttribute('station_staffId');
				sessionStorage.setItem("station_bssorgid", station_bssorgid);
				sessionStorage.setItem("station_regionid", station_regionid);
				sessionStorage.setItem("station_jobid", station_jobid);
				sessionStorage.setItem("station_staffId", station_staffId);
				point=1;
			}
		}
		if(point==0){
			station_bssorgid=selectStationByStaffCode[0].getAttribute('station_bssorgid');
			station_regionid=selectStationByStaffCode[0].getAttribute('station_regionid');
			station_jobid=selectStationByStaffCode[0].getAttribute('station_jobid');
			station_staffId=selectStationByStaffCode[0].getAttribute('station_staffId');
			sessionStorage.setItem("station_bssorgid", station_bssorgid);
			sessionStorage.setItem("station_regionid", station_regionid);
			sessionStorage.setItem("station_jobid", station_jobid);
			sessionStorage.setItem("station_staffId", station_staffId);
		}
		//弹出框返回按钮点击处理
		paramWindow.HANDLE_MYTASK_EVENT.mhowardPopCoverHide();
	}
} (window);
!function(paramWindow) {
    
} (window);
!function(paramWindow) {
	/**绑定回退事件**/
	var goBackElement=document.getElementById('goBack');
	     goBackElement.onclick = function(){
		window.history.back();
	}
} (window);
	